package com.dinzeer.godfox.se;

import com.dinzeer.legendreliclib.lib.compat.slashblade.Drives;
import com.dinzeer.legendreliclib.lib.compat.slashblade.SlashEffect;
import com.dinzeer.legendreliclib.lib.util.FastMakeEntityUtil;
import com.dinzeer.legendreliclib.lib.util.slashblade.AbstractSpecialEffect;
import mods.flammpfeil.slashblade.event.SlashBladeEvent;
import mods.flammpfeil.slashblade.slasharts.Drive;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec3;

public class NeoBlessing extends AbstractSpecialEffect {
    public NeoBlessing() {
        super(30);
    }

    @Override
    public void handleUpdate(SlashBladeEvent.UpdateEvent event, LivingEntity attacker) {
        if (isEffctives(attacker)){
            FastMakeEntityUtil.FastEffect(attacker, MobEffects.JUMP, 1);
            FastMakeEntityUtil.FastEffect(attacker, MobEffects.MOVEMENT_SPEED, 2);
            FastMakeEntityUtil.FastEffect(attacker, MobEffects.DAMAGE_BOOST, 3);
            FastMakeEntityUtil.FastEffect(attacker, MobEffects.DAMAGE_RESISTANCE, 1);
        }

    }

    @Override
    public void handleDoSlash(SlashBladeEvent.DoSlashEvent event, LivingEntity attacker) {
        if (isEffctives(attacker)){
            SlashEffect.SakuraEnd.doSlash(attacker, event.getRoll()+1, Vec3.ZERO , true, event.isCritical(), event.getDamage()/12, event.getKnockback());
            SlashEffect.SakuraEnd.doSlash(attacker, event.getRoll()+2, Vec3.ZERO , true, event.isCritical(), event.getDamage()/12, event.getKnockback());
            SlashEffect.SakuraEnd.doSlash(attacker, event.getRoll()-1, Vec3.ZERO , true, event.isCritical(), event.getDamage()/12, event.getKnockback());
            SlashEffect.SakuraEnd.doSlash(attacker, event.getRoll()-2, Vec3.ZERO , true, event.isCritical(),event.getDamage()/12, event.getKnockback());
            Drive.doSlash(attacker, event.getRoll(), 100, Vec3.ZERO, true, event.getDamage(),3);
        }

    }

    private Boolean isEffctives(LivingEntity attacker){

        if (attacker instanceof Player player){
            return isEffective(this, player.experienceLevel);
        }
        return true;
    }
}
